#include <iostream>
using namespace std;
int n, m, q;
const int N = 1e3 + 10;
int f[N][N];
int x1, y5;
int x2, y2;
int main()
{
    cin >> n >> m>>q;
    for (int i = 1;i <= n;i++)
    {
        for (int j = 1;j <= m;j++)
        {
            int x = 0;
            cin >> x;
            f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + x;
        }
    }
    while (q--)
    {
        cin >> x1 >> y5;
        cin >> x2 >> y2;
        cout << f[x2][y2] - f[x1 - 1][y2] - f[x2][y5 - 1] + f[x1 - 1][y5 - 1] << endl;
    }
    return 0;
}